﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using Semantics;
using Semantics.Base;
using System.Runtime.InteropServices;

namespace Semantics.Example.ParserExample
{
    public partial class CandidatesInterFace : Form
    {
        private string inputText;
        private int index;
        private SortedList<int, Semantics.Parse.AmbiguityResolver.CorrectNode> CorrectNodeList;
        private List<SemanticPosition> Candidates;
        public CandidatesInterFace(string inputText, int index, SortedList<int, Semantics.Parse.AmbiguityResolver.CorrectNode> CorrectNodeList, List<SemanticPosition> Candidates)
        {
            this.inputText = inputText;
            this.index = index;
            this.CorrectNodeList = CorrectNodeList;
            this.Candidates = Candidates;
            InitializeComponent();
            string CandidateValue = Candidates[index].Value;
            string point = "我们分析的句子是‘" + inputText + "'对于子句'"+Candidates[index].Value+"'我们需要做出选择，如果该组组合不正确，请选择拆分；如果正确，对该句进行消岐";
            this.label1.Text = point;
            this.listBox1.Items.Add("子句不正确，进行拆分");
            this.listBox1.Items.Add("子句正确，进行消岐");
        }

        private void ButtonSubmit_Click(object sender, EventArgs e)
        {
            int selectIndex = this.listBox1.SelectedIndex;
            if (selectIndex == -1)
            {
                MessageBox.Show(this, "没有选择有效地项!");
                return;
            }
            else            //进行拆分
            if (selectIndex == 0)
            {               
            }
            //进行消岐
            else
            {
                //flag1表示分析的是子句
                int flag = 1;
                Semantics.Example.ParserExample.ParserForm parse = new Semantics.Example.ParserExample.ParserForm(Candidates[index].Value,flag);
                parse.Show();
            }
        }

        private void listBox1_DoubleClick(object sender, EventArgs e)
        {
            ButtonSubmit_Click(sender, e);
        }
    }
}
